/*
	 Table A3 - Homogeneous group-level summary statistics of cutoffs and assignment variable
*/
 

global replica_dir="<add path to your working directory>"
global data_dir=	"$replica_dir/data"
global output_dir=	"$replica_dir/output"

use "$data_dir/slvl_fin.dta", clear 

la var indicer 	"SNED index"

eststo: estpost summarize indicer  
esttab  using "$output_dir/sumstats_index.tex", cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))")  nonumber  tex nolines fragment label replace  collabels(none) noobs

foreach yr in  2006 2008 2010 2012 2014{
eststo clear 
eststo: estpost summarize indicer if sned_yr==`yr'
esttab  using "$output_dir/sumstats_index.tex", cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))")  nonumber  tex nolines fragment label append  collabels(none) noobs
eststo clear 
}


collapse (firstnm) threshold_1_hg threshold_2_hg , by(hg sned_yr)	
		
count

gen missing_cutoff35=(threshold_2_hg==.)

tab  missing_cutoff35
		

la var threshold_1_hg "Cutoff 100\% vs. 60\%"
la var threshold_2_hg "Cutoff 60\% vs. none"
la var missing_cutoff35 "No partial bonus granted"

eststo: estpost summarize threshold_1_hg threshold_2_hg missing_cutoff35  
esttab  using "$output_dir/sumstats_index.tex", cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))") nonumber  tex nolines fragment label append  collabels(none) noobs

foreach yr in  2006 2008 2010 2012 2014{
eststo clear 
eststo: estpost summarize threshold_1_hg threshold_2_hg missing_cutoff35 if sned_yr==`yr'
esttab  using "$output_dir/sumstats_index.tex", cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))")  nonumber  tex nolines fragment label append  collabels(none) noobs
eststo clear 
}


